//一年中的第几天
//https://leetcode.cn/problems/day-of-the-year/?envType=daily-question&envId=2023-12-31
class Solution {
    char arr[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
public:
    int dayOfYear(string date) {
        int y = stoi(date.substr(0,4));
        int m = stoi(date.substr(5,2));
        int d = stoi(date.substr(8,2));

        for(int i = 0;i<m-1;++i) d += arr[i];
        if((m>=3) && (y % 400 == 0 || (y % 4 == 0 && y % 100 != 0))) ++d;
        return d;
    }
};